import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

import state from './states'
import actions from './actions'
import getters from './getters'
import mutations from './mutations'

// 饿了么UI一些配置属性
import element from './modules/element'

// 自动导入Module模块
let modules = {}
const moduleFiles = require.context('../pages',true,/Module.js$/);
moduleFiles.keys().forEach(key=>{
    const keys = key.replace(/(\.\/|\.js)/g, '')
    // eslint-disable-next-line no-undef
    const moduleName = keys.split('/').pop();
    modules[moduleName] = moduleFiles(key).default;
});

export default new Vuex.Store({
    state,
    actions,
    getters,
    mutations,
    modules: {
        element,
        ...modules
    }
})
